home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0514.ZIP
/
CRAYZ15.ARC
/
VSGEFA.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-08-01
|
6KB
|
122 lines
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }
procedure vSGEFA ( var fID ;
lda, n : integer ;
var IPvt : IVECTOR ;
var InfoCode : integer ) ;
{ PROGRAM: }
{ }
{ SGEFA - Factors Real Single Precision Matrix }
{ Using Gaussian Elimination. }
{ }
{ VERSION: DATE: }
{ }
{ 1.0/TURBO Pascal 3.0 08/02/86 }
{ FORTRAN 08/14/78 }
{ }
{ DESCRIPTION: }
{ }
{ SGEFA is usually called by SGECO, but can be }
{ called directly with a saving in time if RCOND }
{ is not needed. }
{ }
{ (time for SGECO) = (1 + 9/n)*(time for SGEFA) }
{ }
{ On entry; }
{ }
{ A - Matrix to be factored. }
{ lda - Leading dimension of matrix A. }
{ n - Order of matrix A. }
{ }
{ On exit; }
{ }
{ A - Upper triangular matrix and multi- }
{ pliers used to obtain it. Factoriza- }
{ tion can be written; }
{ A = L * U }
{ where L is a product of permutation }
{ and unit lower triangular matrices }
{ and U is upper triangular. }
{ }
{ IPvt - Pivot index vector. }
{ }
{ InfoCode - }
{ = 0 Normal value. }
{ = k If u[k,k] = 0.0. This is not an }
{ error condition for this procedure, }
{ but indicates that SGESL or SGEDI }
{ will divide by zero if called. Use }
{ RCOND from SGECO for reliable indi- }
{ cation of singularity. }
{ }
{ SUBPROGRAMS: }
{ }
{ SAXPY from BLAS }
{ SSCAL from BLAS }
{ ISAMAX from BLAS }
{ }
{ AUTHORS: }
{ }
{ Cleve Moler }
{ University of New Mexico }
{ Argonne National Laboratories }
{ }
{ PASCAL translation; }
{ }
{ Adam Fritz }
{ 133 Main Street }
{ Afton, New York 13730 }
var
gID : vARRAY Absolute fID ;
j, k, l : integer ;
kp1, nm1 : integer ;
t : real ;
begin
{ Gaussian Elimination with Partial Pivoting }
InfoCode := 0 ;
if n > 0 then begin
nm1 := n - 1 ;
for k := 1 to nm1 do begin
kp1 := k + 1 ;
{ Find l = Pivot Index }
iAk := VectorRead(gID,n,k,k,n-k+1,Ak) ;
l := ISAMAX(n-k+1, Ak[iAk], 1) ;
IPvt[k] := l + k - 1 ;
{ Zero Pivot Implies Column Triangularized }
if Ak[iAk+l-1] <> 0.0 then begin
{ Interchange if Necessary }
if l <> 1 then begin
t := Ak[iAk+l-1] ;
Ak[iAk+l-1] := Ak[iAk] ;
Ak[iAk] := t
end ;
{ Compute Multipliers }
t := -1.0/Ak[iAk] ;
SSCAL(n-k, t, Ak[iAk+1], 1) ;
VectorWrite(gID,n,k,k,n-k+1,Ak) ;
{ Row Elimination with Column Indexing }
for j := kp1 to n do begin
iAj := VectorRead(gID,n,k,j,n-k+1,Aj) ;
t := Aj[iAj+l-1] ;
if l <> 1 then begin
Aj[iAj+l-1] := Aj[iAj] ;
Aj[iAj] := t
end ;
SAXPY(n-k, t, Ak[iAk+1], 1, Aj[iAj+1], 1) ;
VectorWrite(gID,n,k,j,n-k+1,Aj)
end
end
else
InfoCode := k
end
end ;
IPvt[n] := n ;
if Aj[iAj+1] = 0.0 then
InfoCode := n
end ;
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }